/*
Copyright 2002-2003 The University of Texas at Austin

Authors: Anthony Thane <thanea@ices.utexas.edu>
Vinay Siddavanahalli <skvinay@cs.utexas.edu>
Advisor: Chandrajit Bajaj <bajaj@cs.utexas.edu>

This file is part of Volume Rover.

Volume Rover is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

Volume Rover is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with iotree; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
#ifndef ISOCONTOURMAP_H
#define ISOCONTOURMAP_H

#include <QList>
#include <QTextStream>
#include "color.h"

namespace PBVP {
	/// 
	class IsocontourMapNode
	{
	public:
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="pos"></param>
		IsocontourMapNode(double pos);
		/// <summary>
		/// Copy Constructor
		/// </summary>
		/// <param name="copy"></param>
        IsocontourMapNode(const IsocontourMapNode& copy);
		/// <summary>
		/// 
		/// </summary>
		virtual ~IsocontourMapNode() {}

		float red() const { return color.r; }
		float green() const { return color.g; }
		float blue() const { return color.b; }

		double position;
		// double value;		// Isovalue 
		Color color;
		int id;

		// give each node a unique ID
		static int ms_NextID;
		static int getNextID() { return ++ms_NextID; }
	};
	/// <summary>
	/// 
	/// </summary>
	class IsocontourMap {
	public:
		/// <summary>
		/// 
		/// </summary>
		IsocontourMap(int maxNumOfNodes = 1);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="copy"></param>
		IsocontourMap(const IsocontourMap& copy);
		/// <summary>
		/// 
		/// </summary>
		virtual ~IsocontourMap() {}

		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetPosition(int index) const;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetPositionOfIthNode(int index) const;
		/// <summary>
		/// 
		/// </summary>
		/// <returns>int</returns>
		int size() const;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="fPosition"></param>
		/// <returns>int</returns>
		int AddNode(double fPosition);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		void DeleteIthNode(int index);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <param name="fPosition"></param>
		void MoveIthNode(int index, double fPosition);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>int</returns>
		int GetIDofIthNode(int index) const;
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <param name="fR"></param>
		/// <param name="fG"></param>
		/// <param name="fB"></param>
		void ChangeColor(int index, double fR, double fG, double fB);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetRed(int index);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetGreen(int index);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="index"></param>
		/// <returns>double</returns>
		double GetBlue(int index);
		/// <summary>
		/// 
		/// </summary>
		/// <param name="stream"></param>
		void saveMap( QTextStream& stream );
		/// <summary>
		/// 
		/// </summary>
		/// <param name="stream"></param>
		void loadMap( QTextStream& stream );

	protected:
		QList<IsocontourMapNode> m_ContourNodes;

		/// The maximum number of isocontour nodes allowed in a map
		/**
		 * For now, only one isocontour node is allowed
		 */
		int m_MaxIsoNodes;
	};
}
#endif
